/**
 * author:Administrator
 * date:2016/1/5
 */

'use strict';
var app = require('koa')();

app.use(require('./router/pre_handler.js'));// logger here
app.use(require('./router/user.js'));

// 404
app.use(function*() {
  this.status = 404;
  this.body = '~~~404 not found~~~';
});

var cfg = require('./config/index.js');
var httpPort = cfg.http.port;
app.listen(httpPort, function () {
  console.log('server listen at localhost:%s', httpPort);
});

var regSelf = require('./reg_self.js');
regSelf(function (err, data) {
  console.log('registry result:');
  if (err) console.log(err);
  else console.log(data);
});